/* eslint-disable */
// 封装的localStorage工具对象，添加了'todo_前缀'
const util = (function () {
  const prefix = 'todo_';
  const StorageGetter = function (key) {
    const store = localStorage.getItem(prefix + key);
    if(store) {  // 如果已经有本地localStorage, 将storage解析
      return JSON.parse(store);
    }else { // 如果没有返回 []
      return [];
    }
  };
  const StorageSetter = function (key, val) {
    if (!val) {
      val = [];
    }
    const stoVal = JSON.stringify(val);
    localStorage.setItem(prefix + key, stoVal);
  };
  return {
    StorageGetter,
    StorageSetter,
  };
}());

export default util;
